<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width"/>
    <title>转诊订单-51问医生</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <script type="text/javascript" src="{{url('./js/jquery-1.8.3.min.js')}}" ></script>
    <link rel="stylesheet" href="{{url('css/weui.min.css')}}">
    <link rel="stylesheet" href="{{url('css/jquery-weui.min.css')}}">
    <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
    <script src="{{url('js/jquery-weui.min.js')}}"></script>
</head>
<body>
<header class="mui-bar mui-bar-nav report-header box-s" id="header" style="background-color: #000000;padding: 3% 3%;text-align: center">
    <a href="javascript:history.go(-1)"><i class="iconfont icon-fanhui fl" style="color: white"></i></a>
    <p style="color: #FFFFFF">确认转诊信息</p>
</header>

<div class="weui-form-preview">
    @if(!is_null($referral->order_num))
        <div class="weui-form-preview__hd">
            <label class="weui-form-preview__label">转诊费用</label>
            <em class="weui-form-preview__value">¥{{$referral->amount}}</em>
        </div>
    @endif
    <div class="weui-form-preview__bd">
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">订单编号</label>
            <span class="weui-form-preview__value">@if($referral){{$referral->order_num}}@endif</span>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">病人姓名</label>
            <span class="weui-form-preview__value">@if($userinfo){{$userinfo->realname}}@endif</span>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">转入医院</label>
            <span class="weui-form-preview__value">@if($hospital){{$hospital->name}}@endif</span>
        </div>
        <div class="weui-form-preview__item">
            <label class="weui-form-preview__label">接诊医生</label>
            <span class="weui-form-preview__value">@if($doctor){{$doctor->doc_name}}@endif</span>
        </div>
    </div>
    <div class="weui-form-preview__ft">
        @if($referral->status == 1)
            <a class="weui-form-preview__btn weui-form-preview__btn_primary" href="javascript:">订单已支付，转诊成功</a>
            @else
            <a class="weui-form-preview__btn weui-form-preview__btn_primary" href="javascript:" id="btn_pay" data-id="{{$referral->order_num}}">现在支付</a>
        @endif
    </div>
</div>
</body>
<script>
    $(function () {
        $("#btn_pay").click(function () {
            var orderNum = $(this).data("id");
            $.post('/api/wechat/wpay',{
                order_num:orderNum
            },function(data,res){
                WXPayment(data.data);
            });
        });

        function WXPayment(configJSON) {
            if (typeof WeixinJSBridge === 'undefined') {
                alert('请在微信在打开页面！');
                return false;
            }
            WeixinJSBridge.invoke('getBrandWCPayRequest', configJSON, function (res) {
                switch (res.err_msg) {
                    case 'get_brand_wcpay_request:cancel':
                        alert('用户取消支付！');
                        break;
                    case 'get_brand_wcpay_request:fail':
                        alert('支付失败！（' + res.err_desc + '）');
                        break;
                    case 'get_brand_wcpay_request:ok':
                        window.location.reload();
                        break;
                    default:
                        alert(JSON.stringify(res));
                        break;
                }
            });
        }
    });
</script>
</html>